cmake_minimum_required (VERSION 2.8)
project(FitAdam)

SET(CMAKE_C_COMPILER ${CMAKE_CXX_COMPILER})
SET(CMAKE_CXX_STANDARD 11)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic -Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")

set(IGL_INCLUDE_DIRS "/home/donglaix/tools/libigl/include/")
include_directories(${IGL_INCLUDE_DIRS})
find_package(OpenCV 2.4 REQUIRED)
find_package( PkgConfig )
pkg_check_modules( EIGEN3 REQUIRED eigen3 )
find_package(OpenMP REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIRS})
find_package(Ceres REQUIRED COMPONENTS SuiteSparse)
include_directories(${CERES_INCLUDE_DIRS})
include_directories("include")
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
find_package(GLEW REQUIRED)
include_directories( ${OPENGL_INCLUDE_DIRS}  ${GLUT_INCLUDE_DIRS} ${GLEW_INCLUDE_DIRS})
find_package(Boost COMPONENTS system filesystem REQUIRED)
include_directories( ${Boost_INCLUDE_DIRS} )

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
find_package(GFlags REQUIRED)

file(GLOB JSON_SOURCES "src/lib_json/*.cpp")
file(GLOB SOURCES "src/*.cpp")
add_library(MYLIB ${SOURCES} ${JSON_SOURCES})

add_executable(run_fitting run_fitting.cpp)
target_link_libraries(run_fitting MYLIB)
target_link_libraries(run_fitting ${OpenCV_LIBS})
target_link_libraries(run_fitting ${CERES_LIBRARIES})
target_link_libraries(run_fitting ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${GLEW_LIBRARY})
target_link_libraries(run_fitting ${GFLAGS_LIBRARY} ${Boost_LIBRARIES})

add_executable(bvh bvh.cpp)
target_link_libraries(bvh MYLIB)
target_link_libraries(bvh ${OpenCV_LIBS})
target_link_libraries(bvh ${CERES_LIBRARIES})
target_link_libraries(bvh ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${GLEW_LIBRARY})
target_link_libraries(bvh ${GFLAGS_LIBRARY} ${Boost_LIBRARIES})

add_library(PythonWrapper SHARED pythonWrapper.cpp)
target_link_libraries( PythonWrapper MYLIB )
target_link_libraries( PythonWrapper ${OpenCV_LIBS} )
target_link_libraries( PythonWrapper ${CERES_LIBRARIES})
target_link_libraries( PythonWrapper ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${GLEW_LIBRARY})
